//------------------------------------------------------------------------------
// <copyright file="CSSqlStoredProcedure.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;

public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void spIO_WriteFile (string file_path, SqlChars contents, bool overwrite)
    {
        // If overwrite and file exists, delete file
        if (overwrite && System.IO.File.Exists(file_path))
            System.IO.File.Delete(file_path);

        // Output the file; allow errors to propogate
        System.IO.File.WriteAllText(file_path, contents.ToSqlString().ToString());
    }
}
